//
//  XDTextFeildCodeTableViewCell.m
//  JintianSeedlings
//
//  Created by iCode on 2016/11/8.
//  Copyright © 2016年 iCode. All rights reserved.
//

#import "XDTextFeildCodeTableViewCell.h"

#import "Masonry.h"

@implementation XDTextFeildCodeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self initSubView];
        
    }
    return self;
}

- (void)initSubView
{
    self.backgroundColor = [UIColor whiteColor];
        
    _codeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [_codeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
    
    _codeBtn.backgroundColor = [UIColor colorWithRed:55.0/255.0 green:154.0/255.0 blue:12.0/255.0 alpha:1];
    
    _codeBtn.titleLabel.font = [UIFont systemFontOfSize:13];
    
    [_codeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    _codeBtn.layer.masksToBounds = YES;
    
    _codeBtn.layer.cornerRadius = 3.0f;
    
    [self.contentView addSubview:_codeBtn];
    
    _textField = [[UITextField alloc]init];
    
    _textField.textColor = [UIColor colorWithRed:38.0/255.0 green:39.0/255.0 blue:40.0/255.0 alpha:1];
    
    _textField.backgroundColor = [UIColor whiteColor];
    
    _textField.placeholder = @"输入验证码";
    
    _textField.keyboardType = UIKeyboardTypeNumberPad;
    
    _textField.returnKeyType = UIReturnKeyDone;
        
    _textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    
    _textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    [self.contentView addSubview:_textField];
    
    [_codeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView.mas_top).with.offset(7.5);
        make.right.equalTo(self.contentView.mas_right).with.offset(-15);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-7.5);
        make.width.mas_offset(SCREEN_WIDTH / 4);
    }];
    
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).with.offset(15);
        make.top.equalTo(self.contentView.mas_top).with.offset(0);
        make.right.equalTo(self.codeBtn.mas_left).with.offset(-10);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
        
    }];
}


@end
